package com.fairytask.logic
{
	import com.fairytask.data.Modulator;
	import com.fairytask.define.SceneDefine;
	import com.fairytask.net.CustomToClientEvent;
	import com.fairytask.ui.MainUI;
	import com.fairytask.ui.main.FunBtnUI;
	import com.fairytask.ui.room.RoomListUI;
	import com.smartfoxserver.v2.entities.data.SFSObject;

	/**
	 * 场景切换逻辑 
	 * @author game
	 * 
	 */	
	public class SceneLogic
	{
		private static var _instance	:SceneLogic;
		private var model:Modulator;
		
		public static function get instance():SceneLogic
		{
			if(null==_instance)
			{
				_instance	=	new SceneLogic();
			}
			return _instance;
		}

		public function SceneLogic()
		{
			model	=	Modulator.instance;
			initEvent();
		}
		
		private function initEvent():void
		{
			model.addEventListener(CustomToClientEvent.SCENE_SWITCH,onSwitchScene);
		}
		
		/**
		 * 切换场景 
		 * @param evt
		 */
		private function onSwitchScene(evt:CustomToClientEvent):void
		{
			var sObj	:SFSObject	=	evt.pData;
			switch(sObj.getUtfString(SceneDefine.TYPE))
			{
				case SceneDefine.ROOM_LIST:
					RoomListUI.instance.show();
					showFuncUI(false);
					break;
			}
		}
		
		/**
		 * 显示功能区 
		 * @param isBattle
		 * 
		 */
		private function showFuncUI(isBattle:Boolean):void
		{
			FunBtnUI.getInstance().show();
		}
	}
}